package com.byq.mm.application.cluster.client;

import com.byq.mm.abstractx.device.Device;
import com.byq.mm.abstractx.engine.CoreEnvironment;
import com.byq.mm.abstractx.protocol.Interaction;
import com.byq.mm.application.cluster.provider.ObdProvider;
import com.byq.mm.application.cluster.provider.TunnelProvider;
import com.byq.mm.foundation.cluster.client.BasicClusterClient;
import com.byq.mm.foundation.cluster.datatype.AttributeValue;
import com.byq.mm.foundation.cluster.datatype.ByteArrayValue;


public class TunnelClient extends BasicClusterClient {

	public TunnelClient(String cluster, Device device, CoreEnvironment e) {
		super(cluster, device, e);
		
	}
	public ByteArrayValue getData(){
		return (ByteArrayValue)getAttributeValue(TunnelProvider.Define.Attributes.DATA);
	}
	public void readData() {
		readAttribute(TunnelProvider.Define.Attributes.DATA);

	}

	
	@Override
	protected Class<? extends AttributeValue> getAttributeType(String attributeName) {
		if(attributeName.equals(TunnelProvider.Define.Attributes.DATA))
			return ByteArrayValue.class;
		
		return null;
	}
	public void subscribe() {
		subscribe(TunnelProvider.Define.Attributes.DATA);

	}
	public void unsubscribe() {
		unsubscribe(TunnelProvider.Define.Attributes.DATA);
	}
	public boolean isSubscribed() {
		return subscribed.get(TunnelProvider.Define.Attributes.DATA);
	}
	public void readSubscribe() {
		readSubscribe(TunnelProvider.Define.Attributes.DATA);
	}
	@Override
	protected void init() {
		attributes.put(TunnelProvider.Define.Attributes.DATA,new ByteArrayValue(new byte[0]));
		subscribed.put(TunnelProvider.Define.Attributes.DATA,  false);
		
	}



}
